package cn.bytecollege.admin.controller; /**
 * @Auther：MR.P
 * @Date:2021/10/28 19 07
 * @Description:根据id查找分类，然后发送数据到修改页面，进行回显
 */

import cn.bytecollege.admin.service.ClassifyService;
import cn.bytecollege.common.entity.Classify;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "ClassifyFindController", value = "/admin/classifyFind")
public class ClassifyFindController extends HttpServlet {
    private ClassifyService classifyService = null;
    public ClassifyFindController(){
        classifyService = new ClassifyService();
    }
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("classifyId");
        Integer classifyId  = Integer.valueOf(id);
        Classify classify = classifyService.findById(classifyId);
        request.setAttribute("classify",classify);
        request.getRequestDispatcher("/admin/html/device/classifyUpdate.jsp").forward(request,response);
    }
}
